#include<string>
#include<vector>
#include<array>
#include<unordered_map>
#include<algorithm>
#include<limits>
#include <stack>
#include<iostream>
#include<sstream>
#include<deque>
#include<queue>
#include<set>
#include<unordered_set>
#define MOD 1000000007
class Solution {
public:
    int distinctSubseqII(std::string s) {
        std::vector<int> dp(26,0);
        int all=1;
        for(int i=0;i<s.size();i++)
        {
            int newN  =(all - dp[s[i]-'a'] + MOD)%MOD;
        
            
            all = (all + newN)%MOD;
            dp[s[i]-'a'] =(dp[s[i]-'a'] + newN)%MOD;
        }
        int ans = 0;
        return (all-1+MOD)%MOD;
    }
};
